(function(_scope) {

var __ = _scope['__'];

var sc, _SELF = __, _CFG, _E = __.Event, _L = __.Lang, _D = __.Dom, _J = __.Json, _I = __.Io;

__.toCall(function() {
  __.initMyFn = function () {
    _CFG = __.cfg;
    sc = __.set('__.config.app');
    _L.objExtend(__.config.app, {
      sPITtId : null, /* sliderPageIndexTimeoutId */
      logContentCache : {},
      MWCDiv : null,
      editorObj : null,
      showingEditor : true,
      rpyDiv : 'quickReplyDiv',
      addDiv : 'quickWriteDiv',
      searchDiv : 'domSearchDiv',
      tagDiv : 'tagSelectDiv',
      calendarDiv : 'domCalendarDiv',
      cookiePre : 'rastauren',
      activeMenu : 0,
      activeTag : null,
      activePage : 1,
      openningLog : null,
      hiLoading : '<span class="st-highlight">Loading...&nbsp;&nbsp;</span>',

      //this is used to store the current mouse over log bar
      mouseOverLog : null,
      mouseOverTab : null,
      dialog : null,

      /* url related */
      index : 0,
      tags : 1,
      log : 1,
   //   writenew : 2,
      member : 2,
   /*   register : 4,*/
      modify : 5,
      sitemap : 6,
      about : 7,
      pageUrl : {
        0 : 'index,mod',
        1 : 'loglist,mod',
 //       2 : 'writenew,mod',
        2 : 'member,mod',
  /*      4 : 'register,mod',*/
        5 : 'modify,mod',
        6 : 'sitemap,mod',
        7 : 'about,mod',
        8 : 'lab,mod',
        login : 'login,mod,dologin,func',
        logout : 'login,mod,dologout,func',
        sendnew : 'writenew,mod,add,func',
        sendmodify : 'modify,mod,add,func',
        sendreply : 'reply,mod,quickadd,func',
        content : 'content,mod',
        doregister : 'register,mod,doregister,func',
        antispam : 'antispam,mod,buildajaxasgroup,func',
        loadreply : 'reply,mod',
        listpage : 'loglist,mod,loadmainrow,func',
        fpnewest : 'loglist,mod,loadfpmainrow,func',
        taghp : 'loglist,mod,loadtagmain,func',
        avtags : 'tags,mod,getavtags,func',
        forgetpwd : 'forgetpwd,func,login,mod',
        changepwd : 'dochange,func,login,mod',
        loadbd : 'loadbd,func,frame,mod',
        loadinitlog : 'loadinitlogs,func,loglist,mod'
      },
      mainRowCId : 'mainRows' /* mainRowsContainerId */,
      regexp : {
        email : /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
      }
    });
    _L.objExtend(__, {

      /* begin of __.syntax */
      syntax : {
        'languages': [
          {
            name : "javascript",
            rules: {
              'comment' : { className: 'comment',	sample: '// ',  exp: /(\/\/[^\n\r]*(?=\n|\r|$))|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/ },
              'regex' : { className: 'constant',	sample: '/_/',  exp: /\/(?:\\[^\n\r\u2028\u2029]|[^\n\r\u2028\u2029*\/])(?:\\[^\n\r\u2028\u2029]|[^\n\r\u2028\u2029\/])*\/(?:[gim]+\b|(?!\w))/ },
              'string' : { className: 'string',	sample: '"_"',  exp: /'(?:\.|(\\\')|[^\''])*'|"(?:\.|(\\\")|[^\""])*"/ },
              'type' : { className: 'type',	sample: 'var',	exp: /\b(?:function|var|this)\b/ },
              'literal' : { className: 'constant',	sample: 'true', exp: /\b(?:true|false|null)\b/ },
              'globals' : { className: 'identifier',	sample: 'NaN',	exp: /\b(?:undefined|Infinity|NaN|Object|Function|Array|String|Boolean|Number|Math|Date|RegExp|Error|arguments|window|document)\b/ },
              'statement' : { className: 'statement',	sample: 'if',	exp: /\b(?:if|else|do|while|for|continue|break|return|with|switch|case|default|try|throw|catch|finally)\b/ },
              'hex' : { className: 'number',	sample: '0xf',	exp: /\b0[xX][a-fA-F0-9]+\b/ },
              'octal' : { className: 'number',	sample: '077',	exp: /\b0[0-7]+\b/ },
              'decimal' : { className: 'number',	sample: '1.1',	exp: /(?:\b(?:0\b|[1-9]\d*)(?:\.\d*)?|\.\d+\b)(?:[eE][-+]?\d+\b)?/ },
              'comparison' : { className: 'operator',	sample: '<=',   exp: /!==|===|==|!=|<=|>=/ },
              'assign' : { className: 'assign',	sample: '=',	exp: /<<=|>>>=|>>=|[-+*%&|^]?=/ },
              'operator' : { className: 'operator',	sample: '<<',	exp: /<<|>>>|>>|--|\+\+|&&|\|\||[-+*\/^%&|^?:<>]|\b(new|delete|void|typeof|instanceof|in)\b/ },
              // ECMAScript Spec section 7.5.2 Keywords:
              'keyword' : { className: 'keyword',	sample: 'this', exp: /\b(?:break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with)\b/ },
              // ECMAScript Spec section 7.5.3 Future Reserved Words:
              'reserved' : { className: 'reserved',	sample: 'long', exp: /\b(?:abstract|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\b/ }
            },
            ignoreCase : false
          },
          {
            name : "css",
            rules: {
              'comment':	    { className: 'comment',	sample: '/* */',	    exp: /\/\*[^*]*\*+([^\/][^*]*\*+)*\// },
              'keyword':	    { className: 'keyword',	sample: '@import',	    exp: /@\w[\w\s]*/ },
              'selector':     { className: 'type',	sample: 'div { }',	    exp: /([\w-:\[.#][^{};>]*)(?={)/ },
              'vendor-prop':  { className: 'todo',    	sample: '-moz-box-sizing:', exp: /(-[\w-]+)(?=\s*:)/ },
              'prop':	    { className: 'statement',   sample: 'color:',	    exp: /([\w-]+)(?=\s*:)/ },
              'units':	    { className: 'number',	sample: '3px',		    exp: /((\d+\.\d+|\d+|\.\d+)(em|en|px|%|pt)|0)\b/ },
              'urls':	    { className: 'string',	sample: 'url(image.png)',   exp: /url\([^\)]*\)/ },
              'string':	    { className: 'string',	sample: '"foo"',	    exp: /'(?:\.|(\\\')|[^\''])*'|"(?:\.|(\\\")|[^\""])*"/ },
              'priority':	    { className: 'keyword',	sample: '!important',	    exp: /!\s*important/ }
            },
            ignoreCase : false
          }
        ],
        'init': function() {
          var codeEls = document.getElementsByTagName("CODE");
          // collect array of all code elements
          codeEls.filter = function(f) {
              var a =  [];
              for (var i = 0; i < this.length; i++) if (f(this[i])) a[a.length] = this[i];
              return a;
          };

          var rules = [];
          rules.toString = function() {
              // joins regexes into one big parallel regex
              var exps = new Array;
              for (var i = 0; i < this.length; i++) exps.push(this[i].exp);
              return exps.join("|");
          };

          // add a token replacment rule
          function addRule(className, rule) {
              // FIXME: we're using a try-block because Safari falls-over using
              // the 'regex' rule from the javascript ruleset.
              // (it works in FF, Opera and IE5.5+ without issue)
              try {
            className = rule.className || className;
            // convert regexs to strings and chop of the slashes
            // (note: style-rule reg-ex's never have any flags, helping slice(1, -1) work)
            var exp = (typeof rule.exp != "string") ? String(rule.exp).slice(1, -1) : rule.exp;
            // calculate number of capturing groups in reg-exp
            var captures;
            if (rule.sample) {
                captures = rule.sample.match(exp).length;
            } else {
                captures = (exp.match(/(^|[^\\])\([^?]/g) || "").length + 1;
            }
            rules.push({
                'className' : className,
                'exp' : '(' + exp + ')',
                'length': captures
                });
            } catch (e) {
              }
          }

          // Escape any HTML-sensitive characters (<, > and &)
          function htmlEncode(string) {
              return string.replace(/[<&>]/g, function(c) { return {'<': '&lt;', '&': '&amp;', '>': '&gt;'}[c] });
          }

          function markup() {
              var i = 0, j = 1, rule;
              while (rule = rules[i++]) {
            if (arguments[j]) {
                return "<span class=\"" + rule.className + "\">" + htmlEncode(arguments[0]) + "</span>";
            } else {
                j += rule.length;
            }
              }
              return htmlEncode(arguments[0]);
          }

          function textNodes(parent) {
              var nodes = [], children = parent.childNodes;
              for (var j = 0, l = children.length; j < l; j++) {
            var child = children[j];
            switch (child.nodeType) {
                case 1:
              nodes.push.apply(nodes, textNodes(child));
              break;
                case 3:
              nodes[nodes.length] = child;
              break;
            }
              }
              return nodes;
          }

          // surrogate element;
          var surrogate = document.createElement('pre');
          function replaceNode(node, html) {
              var parentNode = node.parentNode;
              surrogate.innerHTML = html;
              while (surrogate.firstChild) {
            parentNode.insertBefore(surrogate.firstChild, node);
              }
              parentNode.removeChild(node);
          }

          // normalize source code. tabs -> spaces, smart-quotes -> standard-quotes
          function normalize(text) {
            function spaces() {
              var col = arguments[1] + inserted,
              spaces = '        '.substr(col % 8);
              inserted += spaces.length - 1;
              return spaces;
            }
            var tabs = /\t/g, inserted;
            // replace tabs with spaces:
            text = text.replace(/[^\n\r\u2028\u2029]+/g, function (line) { inserted = 0; return line.replace(tabs, spaces); });
            // replace wordpress's "smart-quotes" with standard quotes: (TODO: fix wordpress)
            text = text.replace(/[\u201c\u201d]/g, '"').replace(/[\u2018\u2019]/g, "'");
            return text;
          }

          function highlight(language) {
            // clear rules array
            rules.length = 0;
            rules.name = language.name;
            // add style rules to parser
            for (var className in language.rules) addRule(className, language.rules[className]);
            var tokens = new RegExp(rules, language.ignoreCase ? "gi" : "g");

            // get stylable elements by filtering out all code elements without the correct className 
            var codeBlocks = codeEls.filter(function(item) { return (item.className.indexOf(language.name) >= 0) });

            var isIE = !!_CFG[4].ie;
            // replace for all elements
            for (var i = 0; i < codeBlocks.length; i++) {

              //add by stauren, once parse
              var cnode = codeBlocks[i];
              var div = document.createElement('div');
              _D.addClass(div, 'code');
              _D.remClass(cnode, language.name);
              cnode.parentNode.insertBefore(div, cnode);
              div.appendChild(cnode);

              // grab text-nodes (recursive)
              var nodes = textNodes(cnode);
              for (var j = 0, l = nodes.length; j < l; j++) {
                var node = nodes[j], text = normalize(node.data);

                // main text parsing and replacement
                var html = text.replace(tokens, markup);

                // Replace line-breaks with explicit HTML for Internet Explorer
                // (implementation should be harmless to other browsers)
                // no, it broke the chrome -- stauren 2009-01-24
                isIE && (html = html.replace(/(\r\n|\r|\n\r|^)( *)/g, function(_,nl,spaces) { return (nl && '<br />&shy;') + Array(spaces.length + 1).join('&nbsp;'); }));
                replaceNode(node, html);
              }
            }
          }

          // run highlighter on all languages
          for (var i = 0; i < this.languages.length; i++) {
              highlight(this.languages[i]);
          }
        }
      }//}}
      /* end of __.syntax */
      ,

      dialog : (function() {
        var pops = [], _createPopup = function() {
          return new __.widget.Popup('', false, {
            modal : true,
            showAfterInit : false
          });
        };

        return {
          getFrame : function(id) {
            /*
            var i = _L.find(pops, function(o) {
              return o.frame.style.display != 'none';
            });
            if (i == -1) {
              i = pops.length;
              pops[i] = _createPopup();
            }
            */
            var frame = _createPopup();
            if (id) {
              frame.frame.id = id;
            }
            return frame;
          }
        };

      }()),

      /*replyHandler  : null,*/
      list : { //-__.list
        closeInitLogs : function(sLeft) { //-__.list.closeInitLogs
          if (sc.openningLogs) {
            _L.e(sc.openningLogs, function(o) {
              if (o != sLeft) {
                __.list.closeLog(o);
              }
            });
            if (sLeft) {
              sc.openningLog = __.list.getLogObj(sLeft);
              //window.scrollTo(0, _.getElXY(sLeft)[1] - 100);
              window.scrollTo(0, _D.getPosition(sLeft, 'offsetTop') - 100);
            }
          }
          sc.openningLogs = null;
          return true;
        }
        ,
        partialLoad : function(vCtn,sTag, iPage) {
          window.scroll(0,0);
          vCtn = _D.$(vCtn)[0];
          var url = sc.pageUrl['taghp'] + ',' + sTag + ',q,' +
            iPage + ',p',
            bcCtn = _D.$('#content .breadc')[0];
          bcCtn.innerHTML = sc.hiLoading;
          __.ajax({
            sUrl : url,
            onOk :function(res){
              res = _J.fromJson(res);
              if (res.bc) {
                sc.activeTag = sTag;
                sc.activePage = iPage;
                vCtn.innerHTML = res.taghome;
                bcCtn.innerHTML = res.bc;
              }
            }
          });
        },
        loadPage : function(page) {
          var div = _D.$(sc.mainRowCId);
          if (div && div[0]) {
            div = div[0];
            var url, lddiv = _D.$('sliderIr')[0];
            if (sc.activeTag != null) {
              url = sc.pageUrl['listpage'] + ',' + sc.activeTag + ',q,' + page + ',p';
            } else {
              url = sc.pageUrl['fpnewest'] + ',' + page + ',p';
            }
            lddiv.innerHTML = sc.hiLoading;
            __.ajax({
              sUrl : url,
              onOk : function(o) {
                var fn = function () {
                  sc.mouseOverLog = null;
                  sc.openningLog = null;
                  sc.openningLogs = null;
                  //TODO : openningLog reInit...
                  sc.activePage = page;
                  div.innerHTML = o;
                  lddiv.innerHTML = '';
                };
                setTimeout(fn, 100);
              },
              onFail : function() {
                div.innerHTML = 'Load failed, please try again later.';
              }
            });
          }
        },
        getLogObj : function(id) {
          var box = _D.$(id);
          if (box[0]) {
            box = box[0];
            var log, reply;
            log = _D.$('.aC', box, true)[0];
            reply = _D.$('.reply', log, true)[0];
            return {
              id : id,
              box : box,
              log : log,
              logC : _D.f('.aCC', log, true),
              ccLi : _D.f('li.tb1', box, true),
              reply : reply,
              rpyList : _D.f('.rpyList', reply, true),
              rpyAction : _D.f('.sdR span', reply, true)
            };
          }
          return false;
        },
        switchlog : function (id) {
          var oLogDom = __.list.getLogObj(id),
            sto = sc.openningLog;

          if (_D.hasClass(oLogDom.box, 'open')) {
            this.closeLog(id);
          } else {
            if (_L.isObject(sto) && sto.id != id) {
              this.closeLog(sto.id);
            }
            __.list.closeInitLogs();
          //  if (!oLogDom.logC.innerHTML) {
            oLogDom.logC.innerHTML = sc.hiLoading;
            this._loadLog(oLogDom);
          //  }
            _D.addClass(oLogDom.box, 'open');
            sc.openningLog = oLogDom;
            __.init.outLogBar();
          }
          window.scrollTo(0, _D.getPosition(oLogDom.box, 'offsetTop') - 100);
          //window.scrollTo && window.scrollTo(0, _D.getElXY(oLogDom.box)[1] - 100);
        },
        closeLog : function (id) {
          var obj, sto = sc.openningLog;
          if (sto && id == sto.id) {
            obj = sto;
          } else {
            obj = __.list.getLogObj(id);
          }
          _D.remClass(obj.box, 'open');

          /* D&D reset */
          var ob = obj.box;
          if(!_D.hasClass(ob, 'r')) {
            ob = ob.parentNode.parentNode;
          }
          ob.style.cssText='';
          ob.moved=false;

          //obj.logC.innerHTML = '';
          //_D.remEl(obj.reply);
          sc.openningLog = null;
          __.reply.closeDiv();
        },
        _loadLog : function(oLogDom) {
          var fill = function(res) {
            sc.openningLog = oLogDom;

        //    (new __.Anim(oLogDom.logC, 'opacity', {from: 1, to: 0, lasttime:350})).run();

            sc.logContentCache[oLogDom.id] = res;
         //   setTimeout(function() {
              __.list._fillLog(oLogDom.id)
         //   }, 400);
          };
          if (typeof sc.logContentCache[oLogDom.id] !== 'undefined') {
            fill(sc.logContentCache[oLogDom.id]);
            return;
          }
          __.ajax({
            sUrl : sc.pageUrl['content'] + ',' + oLogDom.id + ',id',
            onOk : function(o) {
              fill(o);
              /*temp article click count+1*/
              var tempCccArray = oLogDom.ccLi.innerHTML.match(/(\d+)\/(\d+)(.*)/);
              oLogDom.ccLi.innerHTML = tempCccArray[1] + '/' + (tempCccArray[2] - 0 + 1) + tempCccArray[3];
            },
            onFail : function() {
              oLogDom.logC.innerHTML = 'Requested article not found.';
            }
          });
        },
        _fillLog : function (id) {
         // var idAry = id.split('_'),
         //   rpyContent = __.reply.getRpyAction(true, idAry[2]),
          var sto = sc.openningLog;

          //sto.rpyAction.innerHTML = rpyContent;
          sto.logC.innerHTML = sc.logContentCache[id];
          __.syntax.init();
          //(new __.Anim(sto.logC, 'opacity', {from: 0, to: 1, lasttime:500})).run();
        }
      }
      ,
      calendar : {
        /**
         * fnName is the onclick handler of a single date cell
         * fnName is a property of sc
         * fnName accept YYYY-mm-dd as the only param
         */
        opendiv : function(id, initDateStr, fnName) { //calendar.opendiv
          if (_D.$(sc.calendarDiv).length > 0) {
            return;
          }
          //id is associated with the onclick function name
          id = _L.isEmpty(id) ? 'qCbd' : id;
          var fr=__.dialog.getFrame(sc.calendarDiv, 179);// tb=fr.tibase, self=this;
          _D.addText('Choose your date:', fr.tl);
          fr.bd.innerHTML = ['<div id="', id, '" class="bluelink">', this.getCalendarByYmd(initDateStr, id, fnName) , '</div>'].join('');
          fr.on();

          fr.b4ok = function() {
            return true;
          };
          fr.b4off = function() {
            return true;
          };
          return fr;
        }
        ,
        /**
         * @param ymd string YYYY-MM-DD
         * read the comment of calendar.opendiv
         */
        getCalendarByYmd : function(ymd, root, dateClickFnName) {
          var dateClickFn = _L.isFunction(sc[dateClickFnName]) ? sc[dateClickFnName] : function(dt){__.dialog.alert('The date you chose is'+dt);};
          root = _L.isEmpty(root) ? 'ISCr_calendar' : root;

          var clickOneDateFnStr = '__.calendar.' + root + '_clickFn',
            monthArray = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
            getFromYmd = function(str) {
              str = str == undefined ? '' : str;
              var tempDate;
              if (!str.match(/[0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}/)) {
                tempDate     = new Date();
              } else {
                var dArray = str.split('-');
                tempDate = new Date(dArray[0], dArray[1] - 1, dArray[2]);
              }
              return [tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate()];
            },
            getPageChangeFnStr = function (ymdStr) {
              return ['javascript:__.calendar.fillCal', "('", ymdStr ,"','", root,"','", dateClickFnName, "')"].join('');
            },
            dateArray   = getFromYmd(ymd),
            firstDateOfMonth        = new Date(dateArray[0], dateArray[1], 1),
            firstDateOfNextMonth    = new Date(dateArray[0], dateArray[1] + 1, 1),
            fdomd                   = firstDateOfMonth.getDay(),
            dayOfMonthCount         = Math.round((firstDateOfNextMonth - firstDateOfMonth) / (1000 * 3600 * 24)),
            titleDate = monthArray[dateArray[1]] + ', ' + dateArray[0],
            lastYear  = getPageChangeFnStr((dateArray[0] - 1) + '-' + (dateArray[1] + 1) + '-' + dateArray[2]),
            nextYear  = getPageChangeFnStr((dateArray[0] + 1) + '-' + (dateArray[1] + 1) + '-' + dateArray[2]),
            lastMonth = getPageChangeFnStr(dateArray[0] + '-' + dateArray[1] + '-' + dateArray[2]),
            nextMonth = getPageChangeFnStr(dateArray[0] + '-' + (dateArray[1] + 2) + '-' + dateArray[2]),
            dateTbody = '<tr>';

          __.set(clickOneDateFnStr, dateClickFn);

          dateTbody += fdomd > 0 ? '<td colspan="' + fdomd + '"></td>' : '';
          for (var i=fdomd;i<fdomd+dayOfMonthCount;i++) {
            var oneCellDiv = ['<div onmouseover="this.style.cssText=\'background-color: #EECCCC;\'" onmouseout="this.style.cssText=\'background-color: #CCEEFF;\'" onclick="', clickOneDateFnStr, "('", dateArray[0], '-', (dateArray[1] + 1), '-', (i - fdomd + 1), '\')">', (i - fdomd + 1), '</div>'].join('');
            if (i - fdomd + 1 != dateArray[2]) {
              dateTbody += '<td>' + oneCellDiv + '</td>';
            } else {
              dateTbody += '<td style="font-weight:bold;text-decoration:underline;">' + oneCellDiv + '</td>';
            }
            dateTbody += i % 7 == 6 ? '</tr><tr>' : '';
          }
          dateTbody += (i % 7 != 0) ? '<td colspan="' + (6 - (i - 1) % 7) + '"></td></tr>' : '</tr>';
          return ['<div style="text-align:left;float:left;font-size:13px;"><a href="', lastYear, '" title="1 year before">&lt;&lt;</a> <a href="', lastMonth, '" title="1 month before">&lt;</a></div><div style="float:right;text-align:right;font-size:13px;"><a href="', nextMonth, '" title="1 month later">&gt;</a> <a href="', nextYear, '" title="1 year later">&gt;&gt;</a></div><center>', titleDate, '</center><div style="text-align:center;width:99%;padding:1px;"><table class="ISCr_calTable" cellspacing="0" cellpadding="0"><tr><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>', dateTbody, '</table></div>'].join('');
        }
        ,
        fillCal : function(date, container, fnName) {
          container = _L.isEmpty(container) ? 'ISCr_calendar' : container;
          _D.$(container)[0].innerHTML = this.getCalendarByYmd(date, container, fnName);
        }
      }
      ,
      reply : {//-__.reply
        popupHandle : null,
        toggleList : function (id) {
          var aid = id.split('_')[0],
            sto = __.list.getLogObj(id),
            sr = __.reply;

          sc.openningLog = __.list.getLogObj(id);
          //__.list.closeInitLogs(id);

          if (_D.hasClass(sto.rpyList, 'open')) {
            _D.remClass(sto.rpyList, 'open');
            sto.rpyAction.innerHTML = sr.getRpyAction(true, sto.id.split('_')[2]);
          } else {
            _D.addClass(sto.rpyList, 'open');
            sto.rpyList.innerHTML || sr.load(aid);
            sto.rpyAction.innerHTML = sr.getRpyAction(false);
          }
        }
        ,
        openDiv : function (id, oLog) {
          __.list.closeInitLogs(id);
          var aid = id.split('_')[0],
            fr=__.dialog.getFrame(sc.rpyDiv);

          fr.setTitle('Leave a Comment:');

          var emailName = __.Cookie.get(sc.cookiePre +'RPYEN'), name='', email='',
            uri = __.Cookie.get(sc.cookiePre +'RPYURI') || 'http://';
          if (emailName) {
            emailName = emailName.split('@');
            name = emailName.pop();
            email = emailName.join('@');
          }
          fr.setContent({
            cls : 'qWbd', css :'height : 300px;width:400px;',
            child : { tag : 'table', child : {
              tag : 'tbody', child : [{
                tag : 'tr', child : {
                  tag : 'td', cls : 'bluelink', child : {
                    tag : 'table', child : {
                      tag : 'tbody', child : [{
                        tag : 'tr', child : [{
                          tag : 'td', child : {
                            tag : 'input', id : 'reply-name', cls : 'iptRpy', value : name
                          }
                        }, {
                          tag : 'td', child : {
                            tag : 'label', htmlFor : 'reply-name', text : 'Your Name (Requied)'
                          }
                        }]
                      }, {
                        tag : 'tr', child : [ {
                          tag : 'td', child : {
                            tag : 'input', id : 'reply-email', cls : 'iptRpy', value : email
                          }
                        }, {
                          tag : 'td', child : {
                            tag : 'label', htmlFor : 'reply-email',  text : 'E-mail (Required, never displayed)'
                          }
                        }]
                      }, {
                        tag : 'tr', child : [ {
                          tag : 'td', child : {
                            tag : 'input', id : 'reply-uri', cls : 'iptRpy', value : uri
                          }
                        }, {
                          tag : 'td', child : {
                            tag : 'label', htmlFor : 'reply-uri', child : {
                              tag : 'abbr', title : 'Uniform Resource Identifier', text : 'URI'
                            }
                          }
                        }]
                      }]
                    }
                  }
                }
              }, {
                tag : 'tr', child : {
                  tag : 'td', child : {
                    tag : 'textarea', id : 'replyContent', css : 'width:350px;height:150px;'
                  }
                }
              },{
                tag : 'tr', child : {
                  tag : 'td', cls : 'bluelink', child : {
                    tag : 'table', child : {
                      tag : 'tbody', child : [{
                        tag : 'tr', child : [{
                          tag : 'td', cls:'bottom', child : [{
                            tag : 'input', cls : 'iptRpy', id : 'rlyASCode'
                          }]
                        }, {
                          tag : 'td', cls:'bottom', child : {
                            tag : 'span', id : 'asspanSR'
                          }
                        }, {
                          tag : 'td', cls : ['bottom','btna'], child : {
                            html : "&nbsp;<a href=\"javascript:void(0);\" onclick=\"__.misc.getAsGroup('asspanSR')\" class=\"runjs\">Change one</a>"
                          }
                        }]
                      }]
                    }
                  }
                }
              }]
            }}
          });
          fr.setHandler({
            onB4Ok : function() {
              return __.reply.sendFn(aid, oLog);
            }
          });
          this.popupHandle = fr;
          fr.show();

          __.misc.getAsGroup('asspanSR');
        }
        ,
        closeDiv : function () {
          var fr = this.popupHandle;
        //  sc.editorObj && __.editor.hide();
          fr && fr.close();
        }
        ,
        sendFn : function(aid, oLog) {
          var fr = this.popupHandle;
          if (fr.sending) {
            return;
          }
          var rplContent = _L.trim(_D.v('replyContent')),
            rplCode    = _L.trim(_D.v('rlyASCode')),
            rplName    = _L.trim(_D.v('reply-name')),
            rplEmail   = _L.trim(_D.v('reply-email')),
            rplUri     = _L.trim(_D.v('reply-uri')),
            sto;
            if (!oLog) {
              if (!sc.openningLog) {
                __.alert('Error happened!'); 
                return;
              }
            } else {
              sc.openningLog = __.list.getLogObj(oLog.id);
            }
            sto = sc.openningLog;
          if (rplName.length == 0) {
            fr.setNotice('The name can not be empty!');
            return;
          }
          if (rplEmail.length == 0) {
            fr.setNotice('The email can not be empty!');
            return;
          }
          if (rplContent.length == 0) {
            fr.setNotice('The content can not be empty!');
            return;
          }
          if (rplCode.length == 0) {
            fr.setNotice('The verify code can not be empty!');
            return;
          }
          fr.sending = true;

          rplUri = rplUri == 'http://' ? '' : rplUri;

          __.Cookie.set(sc.cookiePre +'RPYEN', [rplEmail, rplName].join('@'));
          __.Cookie.set(sc.cookiePre +'RPYURI', rplUri);

          fr.setNotice('Submitting, please wait...');
          var sentObj = {
            'name'    : rplName,
            'email'   : rplEmail,
            'uri'     : rplUri,
            'content' : rplContent,
            'code'    : rplCode,
            'hash'    : _D.f('asHash').value,
            'aid'     : aid
          };
          __.ajax({
            sUrl : sc.pageUrl['sendreply'],
            sPost : sentObj,
            onOk : function(res) {
              res = _J.fromJson(res);
              if (res && res.code == 200) {
                fr.setNotice(res.message);

                var oldCcAry = sto.ccLi.innerHTML.match(/\d+\/\d+(.*)/);
                sto.ccLi.innerHTML = res.data.replies + '/' + res.data.clickes + oldCcAry[1];
                var idAry = sto.id.split('_'),
                  sr = __.reply;
                idAry[2] = res.data.replies;
                sto.box.id = idAry.join('_');
                sc.logContentCache[sto.box.id] = sc.logContentCache[sto.id];
                sto.id = sto.box.id;

                sr.closeDiv();
                if(!_D.hasClass(sto.rpyList, 'open')) {
                  sto.rpyList.innerHTML = '';
                  sr.toggleList(sto.id);
                } else {
                  sr.load(aid);
                }
              } else {
                fr.setNotice((res&&res.message)||'Error happened!');
              }
              fr.sending = false;
            },
            onFail : function(fr) {
              fr.msg.innerHTML = 'Requested failed, please try again later.';
              fr.sending = false;
            }
          });
          sentObj = null;
          //prevent closing
          return false;
        }
        ,
        load : function (aid) {//-__.reply.load
          var sto = sc.openningLog;
          sto.rpyList.innerHTML = sc.hiLoading;
          __.ajax({
            sUrl : sc.pageUrl['loadreply'] + ',' + aid + ',aid',
            target : sto.rpyList,
            onFail : function() {
              sto.rpyList.innerHTML = 'Fail to load data, please try again later.';
            }
          });
        }
        ,
        getRpyAction : function (tag4open, child) {
          var rpyContent = '<a href="#popupnewrpy" class="runjs" title="Add Comments">Add reply</a>';
          if (!tag4open) {
            rpyContent += ' | <a href="#togglerpy" class="runjs" title="Close Comments">Close reply</a>';
          } else if (typeof child !== 'undefined' && child > 0) {
            rpyContent += ' | <a href="#togglerpy" class="runjs" title="Read Comments">Read reply (' +
              child + ')</a>';
          }
          rpyContent += ' | <a href="#closelog" class="runjs" title="Close log">Close log</a>';
          return rpyContent;
        }
      }
      ,
      editor : { // -__.editor
        container : null,
        init : function(id) {
          /*
          if (sc.editorObj == null) {
            (function() {
              var obj = new YAHOO.widget.SimpleEditor(id, {
                dompath: false,
                animate: true,
                width: '550px',
                height: '250px',
                toolbar: {
                  collapse: false,
                  titlebar: 'Please edit your content below:',
                  draggable: false,
                  buttons: [
                    { group: 'textstyle',
                      buttons: [
                        { type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' },
                        { type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' },
                        { type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' },
                        { type: 'separator' },
                        { type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true },
                        { type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' }
                      ]
                    },
                    { type: 'separator' },
                    { group: 'alignment',
                      buttons: [
                        { type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },
                        { type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },
                        { type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' }
                      ]
                    },
                    { type: 'separator' },
                    { group: 'indentlist',
                      buttons: [
                        { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
                        { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }
                      ]
                    },
                    { type: 'separator' },
                    { group: 'insertitem',
                      buttons: [
                        { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true },
                        { type: 'push', label: 'Insert Image', value: 'insertimage' }
                      ]
                    }
                  ]
                }
              });
              obj._defaultToolbar.buttonType = 'advanced';
              obj.STR_IMAGE_HERE = 'http://';

              //add the Code button
              obj.on('toolbarLoaded', function() {
                var codeBtnConfig = {
                  type: 'push',
                  label: 'Set Code Style',
                  value: 'setcodestyle'
                };
                obj.toolbar.addButtonToGroup(codeBtnConfig, 'textstyle');
                obj.toolbar.on('setcodestyleClick', function(e) {
                  var _range = this._getRange();
                  if (_range.cloneContents) {
                    //FF
                    var _codeWrap = _D.addEl({
                      tag : 'code',
                      cls : 'javascript'
                    });
                    _codeWrap.style.border = '1px dashed #7b1';
                    _codeWrap.style.display = 'block';
                    _codeWrap.appendChild(_range.cloneContents());
                    _range.deleteContents();
                    _range.insertNode(_codeWrap);
                  } else if (_range.htmlText) {
                    //IE7
                    _range.pasteHTML('<code style="border:1px dashed #7b1;display:block;" class="javascript">' + _range.htmlText + '</code>');
                  }
                }, obj, true);
              });
              obj.render();
              sc.editorObj = obj;
              __.editor.container = obj.get('element_cont').get('element');
            })();
          }
          return sc.edtiorObj;
          */
        }
        ,
        hide : function() {
          /*var ret = true;
          if (sc.edtiorObj && sc.editorObj.destroy) {
            ret = sc.editorObj.destroy();
          }
          ret && (sc.editorObj = null);
          return ret;*/

          //_.setElXY(this.container, [-9999, -9999]); just edit 2009-10-01
          this.container.style.visibility = 'hidden';
        }
        ,
        follow : function(dEl, iZindex) {
          //must show at top, but sometimes we want hide it behind ivdiv
          iZindex = iZindex >= 0 ? iZindex : __.topLayer + 1;
         this.container.zIndex = iZindex;
          //_.setElXY(this.container, _.getElXY(dEl));
        }
      }
      ,
      simpleWrite : {
        popupHandle : null,
        openDiv : function() {
          if (!__.login.isLogin()) {
            __.alert('Please sign in first...');
            return;
          }
          var fr=__.dialog.getFrame(sc.addDiv), that = this;// tb=fr.tibase;
          fr.setTitle('Quick Write:');
          fr.setContent({
            cls : 'qWbd', css : 'width:461px;height:450px;', child : {
              tag : 'table', cls : 'nvTbl',  child : [{
                tag : 'tbody', child : [{
                  cls : 'st-table-ruler', child : [{
                    child : {css : 'width:85px;'}
                  }, {
                    child : {css : 'width:120px;'}
                  }, {
                    child : {css : 'width:273px;'}
                  }, {
                  }]
                }, {
                  child : [{
                    cls : 'tbLeft', child : {
                      tag : 'label', htmlFor : 'quickWBTitle', text : 'Title :'
                    }
                  }, {
                    colSpan : '2', child : {
                      tag : 'input', id : 'quickWBTitle'
                    }
                  }]
                }, {
                  cls : 'top10', child : {
                    colSpan : '3', child : {
                      tag : 'textarea', id : 'quickWBContent', css : 'width:441px;height:200px;'
                    }
                  }
                },{
                  cls : 'top10', child : [{
                    cls : 'tbLeft', text : 'Tags :'
                  }, {
                    colSpan : '2', cls:'st-bold', id : 'sw-tags-result', text : 'notag'
                  }]
                },{
                  child : [{
                  }, {
                    cls : ['btna','bottom'], child : {
                      tag : 'a', cls : 'runjs', href : '#otg', id : 'sw-tags', text : 'Loading...'
                    }
                  }, {
                    cls : ['bottom', 'st-lowlight'], text : 'click the button to change'
                  }]
                }, {
                  cls : 'top10', child : [{
                    cls : 'tbLeft', text : 'CAPTCHA :'
                  }, {
                    child : {
                      tag : 'span', id : 'asspanSW'
                    }
                  }, {
                    cls : ['btna','bottom'], child : {
                      html : '<a class="runjs" href="javascript:void(0)" onclick="__.misc.getAsGroup(\'asspanSW\')">Change code</a>'
                    }
                  }]
                }, {
                  child : [{
                  }, {
                    child : {
                      tag : 'input', id :'quickWBASCode', cls : 'iptAS'
                    }
                  }, {
                    cls : ['bottom', 'st-lowlight'], text : 'type what you see'
                  }]
                }]
              }]
            }
          });

          this.popupHandle = fr;
          fr.setHandler({
            onB4Ok : function() {
              that.sendFn();
              return false;
            },
            onB4Cancel : function() {
              if (!that.isEmpty()) {
                __.alert('Your content is not empty!<br />'+
                  'Do you really want to close the dialog?', function(fr) {
                  fr.close();
                  that.closeDiv();
                }, function(o) {
                  o.close();
                });
                return false;
              }
              return true;
            }
          });
          fr.show();

          /*
          var topZ = __.topLayer + 1;
          sc.editorObj.setEditorHTML('');
          __.editor.follow('quickWBContent', topZ);
          var idRteInterval = setInterval(function(){
            _D.f('quickWBContent') || clearInterval(idRteInterval);
            __.editor.follow('quickWBContent', topZ);
          }, 3000);
          _D.f('quickWBContent').visibility = 'hidden';
          */

          __.misc.getAsGroup('asspanSW');
          __.tags.getAvailableTags(function(ary) {
            __.tags.aTags = ary;
            _D.f('sw-tags').innerHTML = 'Add tags('+ ary.length +')';
          });

          //__.editor.init('quickWBContent');
          /*__.tab.closeWriteMenu();*/

        }
        ,
        isEmpty : function() {
          var _title = _D.v('quickWBTitle'),
          _content = _D.v('quickWBContent');
          if( (_title && _title.length > 0) || (_content && _content.length > 0)) {
            return false;
          }
          return true;
        }
        ,
        //accept object or array
        getPopMenu : function(btn, ary) {
          var lists = [];
          _L.isArray(ary) || (ary = [ary]);
          for(var i=ary.length-1;i>-1;i--) {
            lists[i] = '<li><a class="runjs" href="#ctg">'+ ary[i][0] +'</a></li>';
          }
          return '<div class="btna menu"><ul><li><a href="javascript:void(0)" class="runjs">'+ btn +'<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul>'+ lists.join('') +'</ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul></div>';
        }
        ,
        closeDiv : function() {
          //sc.editorObj && __.editor.hide();
          this.popupHandle && this.popupHandle.close();
          this.popupHandle = null;
        }
        ,
        withErr : function(obj) {
          var errMsg = false;
          var title = obj.topic.length;
          if(title <= 0) {
            errMsg = 'Please fill the title';
          } else if (title > 30) {
            errMsg = 'The title should be less than 30 characters';
          } else if (obj.content.length <= 0) {
            errMsg = 'Then content can not be empty';
          } else if (typeof obj.tags == 'undefined' || obj.tags.length <= 0) {
            errMsg = 'Please select at least one tag';
          } else if (obj.code.length <= 0) {
            errMsg = 'Please input the verify code';
          }
          return errMsg;
        }
        ,
        sendFn  : function () {
          var fr = this.popupHandle;
          /* repeat click */
          if (fr.sending) {
            return;
          }

          var i, sentObj, that = this;

          sentObj = {
            topic   : _D.v('quickWBTitle'),
            content : _D.v('quickWBContent'),
            type    : 0,
            code    : _D.v('quickWBASCode'),
            hash    : _D.v('asHash'),
            tags    : _D.f('sw-tags').aSelectedTags,
            uid     : -1 /*for stauren, user check*/
//                'simple'  : 1
          };
          var hasError = this.withErr(sentObj);
          if (hasError !== false) {
            fr.setNotice(hasError);
            return;
          }
          fr.setNotice('Submitting, please wait...');
          fr.sending = true;

          __.ajax({
            sUrl : sc.pageUrl['sendnew'],
            sPost : sentObj,
            onOk : function(res) {
              var resAry = _J.fromJson(res);
              fr.setNotice(resAry.message);
              if (resAry.code == 200) {
                that.closeDiv();
                __.mainwin.load(0);
              }
              fr.sending = false;
            },
            onFail : function(fr) {
              fr.setNotice('Fail to connect server. Please try again later');
              fr.sending = false;
            }
          });
          sentObj = null;
        }
      }
      ,
      drawer : {//-__.drawer
        id : 'rightCabinet',
        anim : [],
        openningId : '',
        //runningCount : 0,
        tOutId : null,
        //rounds used to avoid simultaneously open/closing
        rounds : 0,
        slideOpen : function(el) {
          if(el.id == this.openningId) {
            return;
          }
          /*
          if (__.drawers.runningCount > 1) {
            return;
          }*/
          this.rounds = (this.rounds + 1) % 10;
          var aniAry = this.anim,
            round = this.rounds;
          for(var i in aniAry) {
            if(i == el.id) {
              this.openningId = i;
              _D.remClass(i, 'closed');
              round == this.rounds && aniAry[i].open.run();
            } else {
              if (aniAry[i]['el'].offsetHeight != 0) {
                _D.addClass(i, 'closed');
                aniAry[i].open.stop();
                round == this.rounds && aniAry[i].close.run();
              }
            }
          }
        }
        ,
        toggle : function(dr){
          var right = _D.$('.st-mr .st-dv')[1],
            leftctn = _D.f('st-main');
            left = _D.f('#st-main .st-dv');

          if (_D.hasClass(leftctn, 'no-right')) {
            right.style.display = 'block';
            leftctn.style.marginRight = '-180px';
            left.style.marginRight = '190px';
            _D.remClass(leftctn, 'no-right');
          } else {
            right.style.display = 'none';
            leftctn.style.marginRight = '0px';
            left.style.marginRight = '0px';
            _D.addClass(leftctn, 'no-right');
          }
        }
        ,
        init : function() {
          //this.showTime();
          //_D.$('ISCr_calendar')[0].innerHTML = __.calendar.getCalendarByYmd();

          var drawers = _D.$('#'+this.id+' div.content');
          for(var i=drawers.length-1;i>-1;i--) {
            var oriHeight = drawers[i].offsetHeight,
              openAnim = new __.Anim(drawers[i], 'height', { from: 0, to: oriHeight, lasttime:300, unit:'px' }),
              closeAnim = new __.Anim(drawers[i], 'height', { to : 0, from : oriHeight, lasttime:300, unit:'px' });
            /*
            openAnim.onStart.subscribe(function() {
              __.drawer.runningCount++;
            });
            openAnim.onComplete.subscribe(function() {
              __.drawer.runningCount--;
            });
            closeAnim.onStart.subscribe(function() {
              __.drawer.runningCount++;
            });
            closeAnim.onComplete.subscribe(function() {
              __.drawer.runningCount--;
            });
            */
            this.anim[drawers[i].parentNode.id] = {open:openAnim, close:closeAnim, el:drawers[i]};
          }
          this.slideOpen(drawers[0].parentNode);
        }
        ,
        //timeDiv : _D.f('#drBox2 div.content'),

        showTime : function() {
          var sdt = __.drawer.timeDiv;
          if(sdt && sdt.parentNode &&
            !_D.hasClass(sdt.parentNode, 'closed')) {
            var Digital = new Date(),
              hours = Digital.getHours(),
              minutes = Digital.getMinutes(),
              seconds = Digital.getSeconds(),
              timeNotice = '';
            if (hours <= 5) {
              timeNotice = '<br />Good night!';
            } else if (hours <= 10) {
              timeNotice = '<br />Good morning!';
            } else if (hours <= 13) {
              timeNotice = '<br />Good noon!';
            } else if (hours <= 18) {
              timeNotice = '<br />Good afternoon!';
            } else {
              timeNotice = '<br />Good evening!';
            }
            hours <= 9 && (hours = '0' + hours);
            minutes <= 9 && (minutes = "0" + minutes);
            seconds <=9 && (seconds = "0" + seconds);
            sdt.innerHTML = hours + ':' + minutes + ':' + seconds + timeNotice;
          }
          setTimeout(__.drawer.showTime, 1000);
        }
      }
      ,
      tab : {
        init : function() {
          var tabs = _D.$('#ttab li'), mw = __.mainwin;
          _E.on(tabs, 'mouseout', mw.clearTO, mw, true);
        }
      }
      ,
      search : {
        openDiv : function() {
          var fr=__.dialog.getFrame(sc.searchDiv);// tb=fr.tibase, self=this;
          fr.setTitle('Site search:');
          fr.setContent('<div class="qWbd"><table><tbody><tr><td style="font-family:arial,helvetica,clean,sans-serif;">还没做好呢……只是用来装样子的……</td></tr></tbody></table></div>');
          fr.show();
        }
      }
      ,
      register : { //__.register
        calendarDiv : null,
        openDiv : function() { // register.opendiv
          if (_D.$(sc.searchDiv)[0]) {
            return;
          }
          var fr=__.dialog.getFrame(sc.searchDiv, 540), self=this, tb=fr.tibase;
          fr.setTitle('Register:');
          fr.setContent(['<div class="qWbd" style="width:530px;"><form id="st-register-form"><table class="nvTbl"><thead><tr><td colspan="2">Please fill the table to create your account</td></tr></thead><tbody><tr><th>E-mail:</th><td><input type="text" id="r_email" name="email" value="" class="registerIpt ipt115" tabindex="', ++tb, '"/>&nbsp;<label for="r_email">* Use your email account to login.</label></td></tr><tr><th>Nick Name:</th><td><input type="text" id="r_nickname" name="nickname" value="" class="registerIpt ipt115" tabindex="', ++tb, '" />&nbsp;<label for="r_nickname">* 2 - 15 english letters or numbers</label></td></tr><tr><th>Gender:</th><td><select name="gender" id="r_gender" tabindex="', ++tb, '"><option value="F">Female</option><option value="M">Male</option><option value="N">It\'s a secret.</option></select>&nbsp;<label for="r_gender">Choose one</label></td></tr><tr><th>Announcement:</th><td><textarea type="text" id="r_announce" name="announce" value="" style="height:2.5em;width:250px;" tabindex="', ++tb, '"></textarea>&nbsp;<label for="r_announce">* Less than 200 chars</label></td></tr><tr><th>Birthday:</th><td class="btna"><input type="text" id="r_birthday" name="birthday" value="" class="registerIpt ipt115" readonly="readonly" />&nbsp;<a href="#changebd" class="runjs" id="r_cbirthday" tabindex="', ++tb, '">Change</a> <label for="r_birthday">Choose your birthday</label></td></tr><tr><th>&nbsp;</th><td class="bluelink"><table><tbody><tr><td><span id="regasspan"></span></td><td> Type the characters you see</td></tr><tr><td><input type="text" class="iptAS ipt115" name="asCode" id="r_code" tabindex="', ++tb, '" /></td><td>Can\'t see? <a onclick="__.misc.getAsGroup(\'regasspan\')" href="javascript:void(0);">Change one</a></td></tr></tbody></table></td></tr></tbody></table></form></div>'].join(''));
          fr.setHandler({
            onB4Ok : function() {
              self.doRegister();
            }
          });
          fr.show();
          __.misc.getAsGroup('regasspan');
          /*var _oValidator = new YAHOO.extension.validator('st-register-form', {
            imageBase : '../src/img/',
            onSubmit : false
          });*/
        }
        ,
        openCalendar : function(initDateStr) { //register.openCalendar
          var sca = __.calendar,
            fn = function(dateStr) {
              _D.$('r_birthday')[0].value = dateStr;
              sca.calendarDiv.off();
          }, _sFnName = 'regCalFn';
          sc[_sFnName] = fn;
          var calDiv = sca.opendiv.apply(sca, ['regCalInput', initDateStr, _sFnName]);
          sca.calendarDiv = calDiv;
        }
        ,
        doRegister : function() { //register.doRegister
          var _oRegInfo = __.getObjFromId(['r_email', 'r_nickname', 'r_gender','r_announce', 
            'r_birthday','r_code','asHash']),
            _oCallback = {
              timeout:5000
            };
          if (false) {
          }
          __.$Ajax(sc.pageUrl['doregister'], _oCallback, _oRegInfo);
        }
      }
      ,
      tags : { // -__.tags
        aTags : [],
        getAvailableTags : function(cb) {
          __.ajax({
            sUrl : sc.pageUrl['avtags'],
            onOk : function(res) {
              var result= _J.fromJson(res);
              cb(result);
            }
          });
        }
        ,
        openDiv : function(aTags) {
          aTags = aTags || this.aTags;
          var fr = __.dialog.getFrame(sc.tagDiv),
            selectedTags = _D.f('sw-tags').aSelectedTags || [];//, self=this;
          fr.setTitle('Select Tags:');
          var oEls = {
            cls : 'tags-list', css: 'height:261px;', child : [{
              tag : 'h3', cls : 'b1B', text : 'Public tags:'
            }, {
              tag : 'ul', cls : ['st-fix-float'], child : []
            }]
          };
          var pLis = oEls.child[1].child, prLis, privateAdded = false;
          _L.e(aTags, function(o) {
            var checked = _L.inArray(o[0], selectedTags) ? ' checked="checked"' : '',
              newLi = {tag : 'li', child :[{
              tag : 'span', html : '<input type="checkbox" title="'+ o[1] +'" value="'+ o[0] +'" id="tags-'+ o[0] +'"'+ checked +' />'
            }, {
              tag : 'label', htmlFor : 'tags-'+o[0], title : o[1], text : o[0] 
            }] };
            if (o[2] == '1') {
              pLis[pLis.length] = newLi;
            } else if (o[2] == "2" || o[2] == '3') {
              if (!privateAdded) {
                oEls.child[2] = {
                  tag : 'h3', cls : 'b3B', text : 'Private tags:'
                };
                oEls.child[3] = {
                  tag : 'ul', cls : ['st-fix-float','tags-private'], child : []
                };
                prLis = oEls.child[3].child;
                privateAdded = true;
              }
              prLis[prLis.length] = newLi;
            }
          });
          fr.setContent(oEls);
          fr.setHandler({
            onB4Ok : function() {
              var sel = [];
              _L.e(_D.$('.tags-list li input', fr.frame), function(o) {
                if (o.checked) {
                  sel[sel.length] = o.value;
                }
              });
              _D.f('sw-tags').aSelectedTags = sel;
              _D.f('sw-tags-result').innerHTML = sel.join(',&nbsp; ');
              fr = null;
              return true;
            },
            onOk : function(o) {
              o.close();
            },
            onCancel : function(o) {
              o.close();
            }
          });
          fr.show();
        },

        toggleTag : function(tgt) {
          var name = tgt.innerHTML.replace(/[^a-z0-9]/g,''),
            seSpan = __.$('swTagsChosen')[0],
            avSpan = __.$('swTags')[0],
            updateList = function() {
              //update the 2 lists
              avSpan.innerHTML = __.simpleWrite.getPopMenu('Available('+avAry.length+')', avAry);
              seSpan.innerHTML = __.simpleWrite.getPopMenu('Selected('+seAry.length+')', seAry);
            };

          typeof seSpan.chosenAry == 'undefined' && (seSpan.chosenAry = []);
          var seAry = seSpan.chosenAry, avAry = avSpan.availableTags;
          //var found = false;

          //if the name is part of available list, move it to choosed list
          for(var i=avAry.length-1;i>-1;i--) {
            if (avAry[i][0] == name) {
              seAry[seAry.length] = avAry.splice(i,1)[0];
              updateList();
              return;
            }
          }

          //opposite direction
          for(var m=seAry.length-1;m>-1;m--) {
            if (seAry[m][0] == name) {
              avAry[avAry.length] = seAry.splice(m,1)[0];
              updateList();
              return;
            }
          }
        }
      }
      ,
      login : { // __.login
        loginFr : null,
        isLogin : function() {
          var loginCookie = __.Cookie.get('rastaurenRAW_HASH');
          return !_L.isEmpty(loginCookie);
        },
        updateLoginSt : function() {
          var ck = __.Cookie.get('rastaurenRPYEN'),
            btn = _D.f('st-login-btn');

          if (ck && ck.indexOf('@') > 0) {
            ck = ck.split('@')[2];
          } else {
            ck = '';
          }
          if (ck && this.isLogin()) {
            btn.innerHTML = ck+','+' <a href="#swrite" class="runjs">New</a>&nbsp;&nbsp;<a href="#logout" class="runjs">Sign out</a>';
            btn.href = '#logout';
          } else {
            btn.innerHTML = '<a href="#login" class="runjs">Sign in</a>';
            btn.href = '#login';
          }
        },
        changePwd : function() {
          var value = _L.getObjFromId(_L.w('cpwdhash cpwd2 cpwd1')),
          msg = _D.f('change-password-msg');

          msg.innerHTML = '';
          if (value['cpwd1'].length < 6 || value['cpwd2'].length < 6) {
            msg.innerHTML = 'Password can\'t be shorter than 6';
            return false;
          }
          if (value['cpwd1'] !== value['cpwd2']) {
            msg.innerHTML = '2 passwords are not identical';
            return false;
          }
          _D.f('cpwd1').value = '';
          _D.f('cpwd2').value = '';
          __.ajax({
            sUrl : sc.pageUrl['changepwd'],
            sPost : value,
            onOk : function(res) {
              res = _J.fromJson(res);
              if (res && res.code == 200) {
                __.alert('Your password has been changed.');
                __.mainwin.load(0);
              } else {
                __.alert('Requested failed, please try again later.');
              }
            },
            onFail : function() {
              __.alert('Requested failed, please try again later.');
            }
          });
        }
        ,
        findPwdOpen : function() {
          var fr = __.dialog.getFrame(), self=this;
          fr.setTitle('Find password:');
          fr.setContent('<div class="qWbd"><table class="nvTbl"><tr><th style="text-align:left;">Your registered email :</th></tr><tr><td class="tbLeft" style="text-align:center;">E-mail: &nbsp;<input type="text" class="ipt115" id="fpemail" name="email" value="" style="width:250px;" /></td></tr><tr><td>For any questions, contact <a href="mailto:stauren@stauren.net">stauren@stauren.net</a></td></tr></table></div>');
          fr.setHandler({
            onB4Ok : function() {
              self.findPwdSend(fr);
            }
          });
          fr.show();
        }
        ,
        findPwdSend: function(fr) {
          if (fr.sending === true) {
            return;
          }
          var sMail = _D.v('fpemail');
          if (!sMail.match(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)) {
            fr.setNotice('Please input your email address.');
            return;
          }
          __.ajax({
            sUrl : sc.pageUrl['forgetpwd'],
            sPost : sMail,
            onOk : function(res) {
              res = _J.fromJson(res);
              if (res && res.code == 200) {
                fr.off();
                __.alert('Your request has been sent, <br />please check your email box.');
              } else if (res) {
                __.alert(res.message);
                fr.sending = false;
              } else {
                __.alert('Requested failed, please try again later.');
                fr.sending = false;
              }
            },
            onFail : function() {
              __.alert('Requested failed, please try again later.');
              fr.sending = false;
            }
          });
        },
        loginOpen : function (login) {
          var fr = __.dialog.getFrame(), self=this, ck = __.Cookie.get('RPYEN');
          if (ck && ck.indexOf('@') > 0) {
            ck = ck.split('@')[2];
          } else {
            ck = '';
          }
          fr.setTitle('Login:');
          fr.setContent(
'<div style="width:460px;"><form method="post" action="#" class="loginForm qWbd btna"><table class="nvTbl" width="460">'+
'<tr><th>Name:</th><td><input type="text" class="ipt115" style="width:200px;" name="loginname" id="st-login-name" value="'+ ck +'" tabindex="1101" /></td></tr>'+
'<tr><th>Passwd:</th><td><input type="password" class="songti ipt115" style="width:200px;" id="st-login-pwd" name="loginpwd" tabindex="1102" /></td></tr>'+
'<tr><th>&nbsp;</th><td><input type="checkbox" id="st-login-rem" checked="checked" style="vertical-align:middle;margin:0 3px 2px 0;"/><label for="st-login-rem">Rember me</label></td></tr>'+
'<tr><th>&nbsp;</th><td><input class="runjs stbig" type="submit" id="loginSubmit" value="Login" tabindex="3" onclick="javascript:__.login.doLogin();return false;" />&nbsp;<span id="loginMsg"></span></td></tr>'+
'<tr><td colspan="2" style="text-align:right;"><a class="runjs" href="#register">Register</a>&nbsp;<a class="runjs" href="#fp">Forget password?</a></td></tr>'+
'</table></form></div>'
          );
          fr.setHandler({
            onOk : false,
            onCancel : false
          });
          fr.show();
          this.loginFr = fr;
        },
        doLogin : function (login) {
          var url, dName = _D.f('st-login-name'),
            dPwd = _D.f('st-login-pwd'),
            dErr = _D.f('loginMsg'),
            vRem = !!_D.f('st-login-rem').checked;
            if (!dName || dName.value.length < 1) {
              dErr.innerHTML = 'Please input your name!';
              return false;
            } else if (!dPwd || dPwd.value.length < 1) {
              dErr.innerHTML = 'Please input your password!';
              return false;
            }
            url = sc.pageUrl['login'] + ',' + dName.value + ',loginname,' +
              dPwd.value + ',loginpwd,'+ (vRem ? '1' : '0')+ ',loginrem';
            dPwd.value = '';

          __.ajax({
            sUrl : url,
            onOk : function(o) {
              o = _J.fromJson(o);
              if (o.code == 200) {
                //_D.f('#drBox0 .content').innerHTML = o;
                var l = __.login;
                l.updateLoginSt();
                l.loginFr.close();
                l.loginFr = null;
              } else {
                dErr.innerHTML = o.message;
              }
            },
            onFail : function() {
              _D.f('loginMsg').innerHTML = 'Fail to connect server, please try again later';
            }
          });
        },
        doLogout : function () {
          __.ajax({
            sUrl : sc.pageUrl['logout'],
            onOk : function(o) {
              o = _J.fromJson(o);
              if (o.code = 200) {
                __.login.updateLoginSt();
              }
            },
            onFail : function() {
              _D.f('loginMsg').innerHTML = 'Fail to connect server, please try again later';
            }
          });
        }
      }
      ,
      mainwin : { //-__.mainwin
        tOId : null,
        setTabTitle : function (toSet) {
          var cM  = _D.f('_stcd_ttab_tab' + toSet), cfm = sc.activeMenu;
          var pM  = _D.f('_stcd_ttab_tab' + cfm);
          pM && _D.remClass(pM, 'active');
          if (cM/*toSet >= 0 && toSet <= 8*/) {
            _D.addClass(cM, 'active');
          }
          sc.activeMenu = toSet;
          sc.mouseOverTab = null;
        },
        setTabContent : function (id, page, extra) {
          var url = sc.pageUrl[id];
          if (_L.isInt(page)) {
            url += ',' + page + ',p';
          }

          if (id == sc.tags) {
            sc.activeTag = extra.split(',')[1];
          }
          __.ajax({
            sUrl : url+extra,
            target : sc.MWCDiv,
            onOk : function() {
              if (_D.f('.read-side')) {
                __.twitter.load();
              }
            }
          });
        },
        clearTO : function () {
          if (this.tOId != null) {
            clearTimeout(this.tOId);
            this.tOId = null;
          }
        },
        timeOutLoad : function (toLoad) {
          if (toLoad != sc.activeMenu) {
            __.mainwin.clearTO();
            __.mainwin.tOId = setTimeout(function(){
              __.mainwin.load(toLoad);
            }, 400);
          }
        },
        load : function (toLoad, page, extra) {
          //sc.beLoading = true;
          /* remove the possibly open reply div while page switch*/
          //TODO : create a reInit function
          __.reply.closeDiv();
          sc.openningLog = null;
          sc.openningLogs = null;
          sc.mouseOverLog = null;

          page  = page == undefined ? 1 : page;
          extra = extra == undefined ? '' : extra;
          __.mainwin.setTabTitle(toLoad);
          sc.activePage = page;
          sc.activeTag = null;
          window.scrollTo && window.scrollTo(0, 0);
          sc.MWCDiv.innerHTML = sc.hiLoading;

          this.setTabContent(toLoad, page, extra);
        },
        refresh : function () {
          sc.MWCDiv.innerHTML = '';
          var extra = '', cfm = sc.activeMenu;
          if ((cfm == 1 || cfm == 2) && sc.activeTag) {
            extra = ','+sc.activeTag+',q';
          }
          this.load(cfm, sc.activePage, extra);
        }
      }
      ,
      misc : { //-__.misc
        checkLogin : function() {
          return !!__.Cookie.get('rastaurenRAW_HASH');
        }
        ,
        my64e : function (input) {
          input = __.Tool.encode.encode64(input);
          input = input.replace(/=*$/, '');
          input = input.replace(/L/, '-');
          input = input.replace(/\+/, '_');
          input = input.replace(/\//, ',');
          return input;
        }
        ,
        wrapURL : function (oriUrl) {
//          return sc.baseUrl +'/'+ this.my64e(_L.rand(9999) +',tstamp,1,drfr,' + oriUrl) + '.html';
          return sc.baseUrl +'/'+ this.my64e('1,drfr,' + oriUrl) + '.html';
        }
        ,
        //get the antispam group, include a picture and hash
        getAsGroup : function (id) {
          __.ajax({
            sUrl : sc.pageUrl['antispam'],
            target : _D.$(id)[0]
          });
        }
        ,
        p : function(obj) {
          obj.sUrl = __.misc.wrapURL(obj.sUrl);
          _I.p(obj);
        }
        ,
        getDiffTimeStr : function (milisec) {
          var str = '';
          if (milisec < 60000) { // 60 sec
            milisec = Math.floor(milisec/1000);
            str = milisec <= 1 ? 'second' : 'seconds';
          } else if (milisec < 3600000) { // 60 min
            milisec = Math.floor(milisec/60000);
            str = milisec <= 1 ? 'minute' : 'minutes';
          } else if (milisec < 86400000) { // 24 hours
            milisec = Math.floor(milisec/3600000);
            str = milisec <= 1 ? 'hour' : 'hours';
          } else if (milisec < 2592000000) { // 30 days
            milisec = Math.floor(milisec/86400000);
            str = milisec <= 1 ? 'day' : 'days';
          } else {
            milisec = Math.floor(milisec/2592000000);
            str = milisec <= 1 ? 'month' : 'months';
          }
          return ['about', milisec, str, 'ago.'].join(' ');
        }
      }
      ,
      twitter : {
        /*
        init : function() {
          var dParent = _D.f('.read-side'), that = this;
          if (!dParent) {
            return;
          }
      //    this.createCtn(dParent);

          var that = this;

          _I.p('/twitter', function(t) {
            var obj = _J.fromJson(t);
            if (obj && obj.data && obj.data.length > 0) {
      //        that.fill(obj.data);
            }
            if (obj && !obj.isnew) {
       //       that.refresh();
            }
          });
        },
        createCtn : function(dParent) {
          var id = 'twitter-list', ctn;
          if (_D.f(id)) {
            return;
          }

          var ctn = {
            cls : ['drBox', 'r', 'b1'], id : id, child : [{
              tag : 'b', cls : 'm1'
            }, {
              cls : ['content', 'c1'], child : {
                cls : 'title2', child : {
                  tag : 'a', href : 'http://twitter.com/stauren', html :'stauren@twitter'
                }
              }
            }, {
              tag : 'b', cls : 'm1'
            }]
          };
          ctn = _D.addEl(ctn);
          //_D.insertAfter(ctn, _D.f('word'));
          _D.insertBefore(ctn, dParent.firstChild);
        },
        */
        load : function(doRefresh) {
          var that = this, ref = '';

          if (doRefresh) {
            ref = '/'+ _SELF.misc.my64e('1,refresh');
          }

          _I.p('/twitter'+ ref, function(t) {
            var obj = _J.fromJson(t);
            if (obj && obj.data && obj.data.length > 0) {
              that.fill(obj.data);
            }
          });
        },
        fill : function(t) {
          var uc = [], nowDt = new Date(), tmpDt, ctt, ul;

          _L.e(t, function(o) {
            if (_CFG[4].ie) {
              tmpDt = Date.parse(o.created_at.replace(" +0000",""));
              tmpDt = nowDt - tmpDt;
              tmpDt -= 28800*1000;//8 hours
            } else {
              tmpDt = Date.parse(o.created_at);
              tmpDt = nowDt - tmpDt;
            }
            tmpDt = __.misc.getDiffTimeStr(tmpDt);

            ctt = _L.greplace(o.text,'(\\bhttps?:\\/\\/[^\\s]+)', function(b) {
              var s = b;
              if(b.length>20) {
                s = b.substr(0,20)+'...';
              }
              return '<a href="'+ b +'">'+ s +'</a>';
            });

            uc.push({
              tag : 'li', child : [{
                tag : 'p', html : ctt
              }, {
                tag : 'a',
                href : 'http://twitter.com/stauren/statuses/'+ o.id,
                text : tmpDt,
                cls : 'tw-date'
              }]
            });
          });
          uc = _D.addEl({
            tag : 'ul', child : uc
          });

          ul = _D.f('#twitter-list ul');
          if (ul) {
            _D.remEl(ul);
          }
          _D.insertAfter(uc, _D.f('#twitter-list .title2'));
        }
      }
      ,
      init : { //-__.init
        go : function() { //-__.init.go
          var that = this;
          _D.f('loading-count').innerHTML = '3';
          _D.f('loading-name').innerHTML = 'frame';
          _D.remClass(_D.f('bd'), 'ulink');
          //this.randBackground();

          this.initConfig();

          setTimeout(function() {
            that.loadBd();
          });
        },
        genBd : function() {
          __.ajax({
            sUrl : sc.pageUrl['loadbd'] +','+_CFG[0][7]+',rawget,1,regen',
            onOk : function(t) {
            }
          });
        },
        loadBd : function() {
          var that = this;
          __.ajax({
            sUrl : sc.pageUrl['loadbd'] +','+_CFG[0][7]+',rawget',
            onOk : function(t) {
              var init = __.init, twiObj, isBdNew;

              isBdNew = t.substr(0, 1) === '1';
              t = _J.fromJson(t.substr(1));
              _D.f('bd').innerHTML = t.frame;

              if (t.tj && _D.f('twitter-list')) {
                twiObj = _J.fromJson(t.tj);
                __.twitter.fill(twiObj.data);
              }

              if (_CFG[0][7].match(/^log\/[0-9a-z]+\.html$/)) {
                _D.f('content').appendChild(_D.f('single-content'));
              }

              sc.MWCDiv = _D.f('content');
              __.tab.init();
              if (_CFG[0][7] != '') {
                __.drawer.toggle();
              }
              __.mainwin.setTabTitle(sc.activeMenu);
              __.drawer.init();

              sc.activeTag = sc.activeTag ? sc.activeTag : null;
              _E.on(document.body, 'click', init.bdClickHandler);
              _E.on('mwindow', 'mousedown', init.ddHandler);
              _E.on('doc2', 'mouseover', init.mOverHandler, init, true);
              _E.on('ttab', 'mouseover', init.tabMOHandler, init);

              __.ajax({
                sUrl : sc.pageUrl['loadinitlog'],
                onOk : function(t) {
                  _D.f('.pl-main').innerHTML += t;
                }
              });
          //    __.syntax.init();

              if (twiObj && !twiObj.isnew) {
                __.twitter.load(true);
              }

              __.login.updateLoginSt();

              if (!isBdNew) {
                window.setTimeout(function() {
                  that.genBd();
                }, 2000);
              }

              if (sc.loadGa) {
                __.load('http://www.google-analytics.com/urchin.js', function(){
                  window._uacct = "UA-1092757-1";
                  urchinTracker();
                });
              }
            }
          });
        },
        initConfig : function() {
          var pageCfg = _CFG[0];
//0:baseUrl,1:activeMenu,2:activeTag,3:activePage,4:initOLogs array,5:initOlog id,6:load ga,7:raw get
          sc.baseUrl = pageCfg[0]; 
          sc.activeMenu = pageCfg[1];
          sc.activeTag = pageCfg[2];
          sc.activePage = pageCfg[3];
          if (pageCfg[4].length > 0) {
            sc.openningLogs = pageCfg[4];
          }
          if (pageCfg[5]) {
            sc.openningLog = __.list.getLogObj(pageCfg[5]);
          }
          sc.loadGa = !!pageCfg[6];
        },
        randBackground : function() {
          var picList = _L.w('1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7.jpg 8.jpg 9.jpg 10.gif');
          _document.body.background = '#303040 url(/misc/images/bg_flower'
            + picList[_L.rand(picList.length - 1)]
            + ') repeat scroll 0 top';
        }
        ,
        overLogBar : function(obj) {
          if (sc.mouseOverLog) {
            this.outLogBar();
          }

          if (_D.hasClass(obj.parentNode, 'i')) {
            _D.addClass(obj.parentNode.parentNode, 'over');
          }
          _D.addClass(obj, 'over');
          sc.mouseOverLog = obj;
        },
        outLogBar : function() {
          var obj = sc.mouseOverLog;
          if (obj) {
            if (_D.hasClass(obj.parentNode, 'i')) {
              _D.remClass(obj.parentNode.parentNode, 'over');
            }
            _D.remClass(obj, 'over');
            sc.mouseOverLog = null;
          }
        },
        findLogBox : function(tp) {
          var logO;
          tp = tp.parentNode;
          while(tp != sc.MWCDiv &&
              tp != document.body) {
            if (_D.hasClass(tp, 'logBox')) {
              logO = tp;
              break;
            }
            tp = tp.parentNode;
          }
          return logO;
        },
        runFns : {
          pc : function(target, href) {
            href = href.substr(0, href.indexOf('#'));
            /* analyse the href which start with baseUrl */
            if (href == sc.baseUrl || href == (sc.baseUrl+'/')) {
              __.mainwin.load(0);
              return;
            }
            href = href.substr(sc.baseUrl.length + 1).split('/');
            if (sc[href[0]] !== undefined &&
                sc.pageUrl[sc[href[0]]] !== undefined
            ) {
              //sc[href[0]] == tab id
              var extra = href.length > 1 ? ','+href[1]+',q' : '';
              if (href[0] == 'tags') {
                var oReadCtn = _D.$('#content .read-main .pl-main');
                if (oReadCtn[0]) {
                  sc.openningLogs = null;
                  sc.openningLog = null;
                  __.list.partialLoad(oReadCtn[0], href[1], 1);
                  return;
                }
              }
              __.mainwin.load(sc[href[0]], 1, extra);
            }
          },
          popupnewrpy : function(target) {
            var logO = __.init.findLogBox(target);
            logO && logO.id &&
              __.reply.openDiv(logO.id, logO);
          },
          togglerpy : function(target) {
            var logO3 = __.init.findLogBox(target);
            logO3 && logO3.id && __.reply.toggleList(logO3.id);
          },
          closelog : function(target) {
            var logO2 = __.init.findLogBox(target);
            logO2 && logO2.id && __.list.switchlog(logO2.id);
          },
          reload : function() {
            __.mainwin.refresh();
          },
          swrite : function() {
            __.simpleWrite.openDiv();
          },
          otg : function() {
            __.tags.openDiv();
          },
          ctg : function() {
            //__.tags.toggleTag(target);
          },
          sitesearch : function() {
            __.search.openDiv();
          },
          register : function() {
            //__.alert('Sorry, 开发中……');
            __.register.openDiv();
          },
          ntag : function() {
            __.alert('Sorry, 创建新 Tag 功能开发中……');
          },
          fp : function() {
            __.login.findPwdOpen();
          },
          login : function() {
            __.login.loginOpen();
          },
          logout : function() {
            __.login.doLogout();
          },
          changebd : function() {
            var _tmpDs = _D.f('r_birthday');
            _tmpDs = _tmpDs ? _tmpDs.value : '';
            __.register.openCalendar(_tmpDs);
          },
          ttab : function(target) {
            var id = target.id, num;
            if (_L.isString(id) && /^_stcd_/.test(id)) {
              num = parseInt(id.substr(14), 10);
              if (num >= 0) {
                __.mainwin.load(num);
               // __.mainwin.timeOutLoad(id);
              } else if (id.substr(14) == 'mover') {
                __.drawer.toggle();
              }
            }
          }
        },
        tabMOHandler : function(ev) {
          ev = ev || window.event;
          var target = ev.target || ev.srcElement, id;
          if (target && target.tagName == 'SPAN') {
            target = target.parentNode;
          }
          if (target.parentNode && target.parentNode.id=='ttab' &&
            !_L.endWith(target.id, sc.activeMenu+'')) {
            _D.addClass(target, 'active');
            sc.mouseOverTab = target;
            _E.stopEvent(ev);
          }
        },
        mOverHandler : function(ev) {
          ev = ev || window.event;
          var target = ev.target || ev.srcElement, id;

          while (target != document.body) {
            //_stod is a preserved class name, mean it will trigger overhandler
            if (!_D.hasClass(target, '_stod')) {
              target = target.parentNode;
              continue;
            }
            id = target.id;
            //single mouseover event will be handled with an id start as '_stod_'

            if (_D.hasClass(target, 'drBoxTgl')) {
              var tnode = target.parentNode;
              __.drawer.tOutId && clearTimeout(__.drawer.tOutId);
              __.drawer.tOutId = setTimeout(function(){
                __.drawer.slideOpen(tnode)
              }, 400);
            } else if (_D.hasClass(target, 'logBox')) {
              //if(!sc.openningLog || target != sc.openningLog.box) {}
              if(!_D.hasClass(target, 'open')) {
                __.init.overLogBar(target);
                return;
              }
            }
            target = target.parentNode;
          }
          __.init.outLogBar();
          if (sc.mouseOverTab) {
            _D.remClass(sc.mouseOverTab, 'active');
            sc.mouseOverTab = null;
          }
        }
        ,
        ddHandler : function (ev) {
          ev = ev || window.event;
          var target = ev.target || ev.srcElement;
          if (target.id && target.id == 'sliderPI') {
            /* className = allPI123 */
            var allp = parseInt(target.className.substr(5)) - 1,
              fnUp = function(x,y,zone) {
                var page = Math.round((x - zone.left) / (zone.right - zone.left) * allp) + 1;
                if (!_L.isNull(sc.sPITtId)) {
                  clearTimeout(sc.sPITtId);
                  sc.sPITtId = null;
                }
                var fnLoad = function(){
                  __.list.loadPage(page);
                };
                if (sc.activePage != page) {
                  sc.sPITtId = setTimeout(fnLoad, 500);
                }
              },
              fnMove = function(x,y,zone) {
                var page = Math.round((x - zone.left) / (zone.right - zone.left) * allp) + 1;
                target.innerHTML = page;
              };
            __.Drag.handler(ev, target, false, {'t':0, 'r':225, 'b':0, 'l':0}, fnUp, fnMove);
          } else if (_D.hasClass(target, 'aCC')) {
            var lb = target.parentNode.parentNode;
            if (!_D.hasClass(lb, 'r')) {/* deal with 2 kind of logbox*/
              lb = lb.parentNode.parentNode;
            }
            __.Drag.handler(ev, lb);
          }
        }
        ,
        bdClickHandler : function(ev) {
          ev = ev || window.event;
          var target = ev.target || ev.srcElement, tag;

          //find a tag with certain className to process, or capture the click on openable bars
          while(target && target != sc.MWCDiv && target != document.body) {
            tag = target.tagName.toLowerCase();
            if (_D.hasClass(target, 'runjs')) {
              _E.stopEvent(ev);
              var href = target.href || target.id, match, runFns = __.init.runFns;
              if (tag == 'a') {
                match = target.href && target.href.match(/#(.*)$/);
              } else {
                //_stcd_ttab_tab0
                match = target.id && target.id.match(/^_stcd_([^_]*)_/);
              }
              if (match && runFns[match[1]]) {
                 runFns[match[1]](target, href);
                 __.login.updateLoginSt();
              }
              return;
            } else if (_D.hasClass(target, 'aTB')) {
              _E.stopEvent(ev);
              __.list.switchlog(target.parentNode.id);
              return;
            } else if (tag == 'a') {
              if (target.href != '#' && target.href != '/' &&
                !_L.startWith(target.href, 'javascript:')) {
                target.target = "_blank";
              }
            }
            target = target.parentNode;
          }
        }
      }
    });
    __.ajax = __.misc.p;
    __.alert = (function() {
      return function(s, yes, no) {
        var pop = new __.widget.Popup('', false, {
          modal : true,
          showAfterInit : false,
          onClose : false
        });
        pop.setContent(s);
        pop.setHandler({
          onOk : yes ? yes : function(o) {o.close()},
          onCancel : no ? no : false
        });
        pop.show();
      };
    }());
/*
    if (_SC.initConfig) {
      //try {__.initConfig();} catch(e) {}
      _SC.initConfig();
    }
    */
    __.init.go();
  };
  __.Event.onReady(__.initMyFn);
}, '__.Lang');

})(window);
